#include "view_time_3.inc"

#include "view_time_3.h"

#include "view_time_0.h"
#include "display_ctrl.h"
#include "platform_assert.h"
#include "lfs_file_manager_auto.h"
#include "rtc.h"
#include "datetime.h"
#include "blecom.h"
#include "battery_ctrl.h"
#include "sport_his.h"
#include "display_ctrl.h"
#include "display_interface_240x240.h"
#include "datetime.h"
#include "heart_rate_interface.h"
#include "font/num_font.h"
#include "font_mngr.h"
#include "view_common.h"
#include "app_trace.h"
#include "weather_ctrl.h"
#include "view_times.h"
#ifdef TIME_3_SKIP
#else
static void view_time_3_time_background(void)
{
	_disp_show_flash_img(DISP_LFS_FILE_INDEX_4,4,24,FILE_IMG_back_dial);
}

static void view_time_3_time_hand(void)
{
	if(disp_ctrl.loop_cnt == 0)
	{
		disp_ctrl.auto_refresh_time = 1000;
		uint16_t temp16 = get_present_day_minute();
		disp_ctrl.com_data.i_temp[32] = (temp16/2)/6*6%360;
		disp_ctrl.com_data.i_temp[33] = (temp16*2)/6*6%360;
	}
	disp_draw_img_rotate(img_time_3_time_hour_hand, 0, 63 , (63 << 16) | 83, disp_ctrl.com_data.i_temp[33]);
  disp_draw_img_rotate(img_time_3_time_minute_hand, 0, 61, (63 << 16) | 83, disp_ctrl.com_data.i_temp[32]);
}

static void view_time_3_time(void)
{
	int x = 14;
	int y = 173;
	int front_width = 21;
	int front_spacing = 5;
	int point_width = 5;
	
	int img_time_3_time_num_TAB[] = 
	{
		FILE_IMG_num_21_27_0,
		FILE_IMG_num_21_27_1,
		FILE_IMG_num_21_27_2,
		FILE_IMG_num_21_27_3,
		FILE_IMG_num_21_27_4,
		FILE_IMG_num_21_27_5,
		FILE_IMG_num_21_27_6,
		FILE_IMG_num_21_27_7,
		FILE_IMG_num_21_27_8,
		FILE_IMG_num_21_27_9,
	};
	
	_disp_show_flash_img(DISP_LFS_FILE_INDEX_0,x,y,img_time_3_time_num_TAB[disp_ctrl.com_data.i_temp[3]/10]);
	x+=(front_width+front_spacing);
	_disp_show_flash_img(DISP_LFS_FILE_INDEX_1,x,y,img_time_3_time_num_TAB[disp_ctrl.com_data.i_temp[3]%10]);
	x+=(front_width+front_spacing);
	disp_draw_user_image_filter_color(x,y,img_time_3_colon);
	x+=(point_width+front_spacing);
	_disp_show_flash_img(DISP_LFS_FILE_INDEX_2,x,y,img_time_3_time_num_TAB[disp_ctrl.com_data.i_temp[4]/10]);
	x+=(front_width+front_spacing);
	_disp_show_flash_img(DISP_LFS_FILE_INDEX_3,x,y,img_time_3_time_num_TAB[disp_ctrl.com_data.i_temp[4]%10]);
}

void view_time_3_display(void)
{
	view_time_3_time_background();
	view_time_3_time_hand();
	view_time_3_time();
	show_time_0_ble(disp_ctrl.com_data.i_temp[6]);
  show_time_0_battery(disp_ctrl.com_data.i_temp[7]);
	
}
#endif
